<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:sec="http://www.springframework.org/security/facelets/tags">

<h:body>
	<ui:composition template="/templates/templatePrincipal.xhtml">
		<ui:param name="tituloCadastro" value="Cadastro de Usuários" />
		<ui:param name="tituloPesquisa" value="Pesquisa de Usuários" />
		<ui:param name="tituloGrid" value="Lista de Usuários" />
		<ui:param name="mbean" value="${recuperarSenhaMB}" />
		<ui:define name="content">
			<p:outputPanel rendered="#{not mbean.autenticado}">
				<h:form>
					<p:toolbar>
						<p:toolbarGroup align="right">
							<p:commandButton title="#{msg.acaoRecuperarSenha}"
								value="#{msg.acaoRecuperarSenha}"
								action="#{mbean.recuperarSenha}" icon="ui-icon-disk"
								update="@form" />
						</p:toolbarGroup>
					</p:toolbar>
					<h:outputText value="#{msg.msgRecuperarSenha}" />
					<p:focus for="campoPesquisa" />
					<p:panel header="Dados do Usuário">
						<h:panelGrid columns="3">
							<h:outputText value="Informe o login ou email: " />
							<p:inputText value="#{mbean.pesquisa}" size="54" maxlength="50"
								label="login ou email" id="campoPesquisa" required="true" />
							<p:message for="campoPesquisa" showDetail="true"
								showSummary="true" />

							<sec:ifAllGranted roles="ROLE_SYSADMIN">
							<h:outputText value="Novo Email (Somente se desejar alterar o email): " />
							<p:inputText value="#{mbean.novoEmail}" size="54" maxlength="50"
								label="Novo Email" id="novoEmail" required="false" validator="emailValidator"/>
							<p:message for="novoEmail" showDetail="true" showSummary="true" />
							</sec:ifAllGranted>
						</h:panelGrid>
					</p:panel>

					<p:growl showSummary="true" showDetail="true" globalOnly="true" />
				</h:form>
			</p:outputPanel>

			<p:outputPanel rendered="#{mbean.autenticado}">
				<h:form>
					<h1>Faça o logout com o usuário logado e tente novamente!</h1>
					<p:poll interval="5" listener="#{mbean.redirecionar}"
						global="false" />
				</h:form>
			</p:outputPanel>
		</ui:define>
	</ui:composition>
</h:body>
</html>
